#!/usr/bin/env bash
#=======================================================================
#        FILE: testall.sh
# DESCRIPTION: Runs test suite under all supported versions of Python
#              and displays failures when encountered.
#=======================================================================

#-----------------------------------------------------------------------
# Define function (takes command to run as a single argument).
#-----------------------------------------------------------------------
run_command ()
{
    echo "" 1>&2
    echo "======================================================================" 1>&2
    echo "$1" 1>&2
    echo "======================================================================" 1>&2
    $1  # <- Run command.
    if [ $? -ne 0 ]  # Check exit status of completed command.
    then
        echo "" 1>&2
        echo "Failed Command: $1"1>&2
        exit $?  # <- EXIT!
    fi
}

#-----------------------------------------------------------------------
# Run test suite in all supported versions of Python.
#-----------------------------------------------------------------------
run_command "python3.3 -B runtests.py"
run_command "python3.2 -B runtests.py"
run_command "python3.1 -B runtests.py"
run_command "python2.7 -B runtests.py"
run_command "python2.6 -B runtests.py"
run_command "python2.5 runtests.py"
run_command "python2.4 runtests.py"

echo "" 1>&2
echo "All commands successful." 1>&2
